package raf;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.io.UnsupportedEncodingException;

/**
 * 向文件中写入文本数据
 */
public class WriteStringDemo {
    public static void main(String[] args) throws IOException {
        RandomAccessFile xiu=new RandomAccessFile("xiu.txt","rw");
        String line="张无忌战六大门派落败后，被囚少林寺地牢，习得吸星大法，功成后破牢而出，血洗武林！\n";
        byte[]data=line.getBytes("UTF-8");
        xiu.write(data);

        String line1="周芷若习得倚天屠龙秘籍，坐上武林盟主，率领群雄和魔教教主张无忌大战三天三夜。";
        xiu.write(line1.getBytes("UTF-8"));
        System.out.println("写出完成");
        xiu.close();
    }
}
